package com.draem0507.refactor;

/**
 * @title 拓展工厂类
 * @desc
 * @atuh lwx
 * @createtime on 2015/11/14 14:05
 */
public class Day_19 {





    public interface IPoliceCarFactory
    {
        PoliceCar Create(int mileage, boolean serviceRequired);
    }

    public class PoliceCarFactory implements IPoliceCarFactory
    {
        public PoliceCar Create(int mileage, boolean serviceRequired)
        {
            PoliceCar policeCar = new PoliceCar();
            policeCar.ServiceRequired = serviceRequired;
            policeCar.Mileage = mileage;
            return policeCar;
        }
    }

    public class PoliceCarController1
    {
        public IPoliceCarFactory PoliceCarFactory ;

        public PoliceCarController1(IPoliceCarFactory policeCarFactory)
        {
            PoliceCarFactory = policeCarFactory;
        }

        public PoliceCar New(int mileage, boolean serviceRequired)
        {
            return PoliceCarFactory.Create(mileage, serviceRequired);
        }
    }


    public class PoliceCarController
    {
        public PoliceCar New(int mileage, boolean serviceRequired)
        {
            PoliceCar policeCar = new PoliceCar();
            policeCar.ServiceRequired = serviceRequired;
            policeCar.Mileage = mileage;

            return policeCar;
        }
    }

    class PoliceCar{

        public boolean ServiceRequired;
        public int Mileage;
    }
}
